package cn.crce.cloud9.comp;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * @author OnCloud9
 * @description
 * @project NRCE-TEST
 * @date 2022年09月12日 下午 10:50
 */
public class Case12 implements ActionListener {
    public static void main(String args[]) {
        Case12 t = new Case12();
        //*********Found**********
        JFrame f = new JFrame("Test");
        JButton b = new JButton("复制文件");
        b.setSize(100, 40);
        b.addActionListener(t);
        f.setSize(400, 400);
        //*********Found**********
        f.getContentPane().add(b);
        f.pack();
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    public void actionPerformed(ActionEvent event) {
        try {
            //*********Found**********
            FileInputStream in = new FileInputStream("a.txt");
            //*********Found**********
            FileOutputStream out = new FileOutputStream("b.txt");
            int c;
            while ((c = in.read()) != -1)
                out.write(c);
            in.close();
            out.close();
        } catch (Exception e) {
        }
    }
}

